﻿using Colorful.Furniture.Localization;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Localization;

namespace Colorful.Furniture.Permissions;

/// <summary>
///  权限定义提供者
/// </summary>
public class FurniturePermissionDefinitionProvider : PermissionDefinitionProvider
{
    public override void Define(IPermissionDefinitionContext context)
    {
        //系统管理
        var sysManageGroup = context.AddGroup(FurniturePermissions.SysManageGroup,L(FurniturePermissions.SysManageGroup));

        //管理员权限
        var managerPermission = sysManageGroup.AddPermission(FurniturePermissions.ManagerPermission.Default, L(FurniturePermissions.ManagerPermission.Default));
        managerPermission.AddChild(FurniturePermissions.ManagerPermission.Add, L(FurniturePermissions.ManagerPermission.Add));
        managerPermission.AddChild(FurniturePermissions.ManagerPermission.Update, L(FurniturePermissions.ManagerPermission.Update));
        managerPermission.AddChild(FurniturePermissions.ManagerPermission.Delete, L(FurniturePermissions.ManagerPermission.Delete));
        managerPermission.AddChild(FurniturePermissions.ManagerPermission.Set, L(FurniturePermissions.ManagerPermission.Set));
    }

    private static LocalizableString L(string name)
    {
        return LocalizableString.Create<FurnitureResource>(name);
    }
}
